<?php include './admin/view/header.inc.htm';?>

<div class="panel">
	<div class="header">插件详情</div>
	<div class="body">
		<table class="form">
			<tr>
				<td>插件图标：</td>
				<td><img src="<?php echo $plugin['icon_url']; ?>" width="54" height="54" /></td>
			</tr>
			<tr>
				<td>插件名：</td>
				<td><?php echo $plugin['name']; ?> v<?php echo $plugin['version']; ?></td>
			</tr>
			<tr>
				<td>要求 BBS 最低版本：</td>
				<td>v<?php echo $plugin['bbs_version']; ?></td>
			</tr>
			<tr>
				<td>目录：</td>
				<td><?php echo $dir; ?></td>
			</tr>
		<?php if(!empty($plugin['username'])) { ?>
			<tr>
				<td>作者：</td>
				<td><?php echo $plugin['username']; ?></td>
			</tr>
		<?php } ?>
		<?php if(!empty($plugin['email'])) { ?>
			<tr>
				<td>Email：</td>
				<td><?php echo $plugin['email']; ?></td>
			</tr>
		<?php } ?>
			<tr>
				<td>介绍：</td>
				<td><?php echo $plugin['brief']; ?></td>
			</tr>
		<?php if($plugin['is_official']) { ?>
			<tr>
				<td>价格：</td>
				<td><?php echo $plugin['price']; ?></td>
			</tr>
			<tr>
				<td>用户评级：</td>
				<td><?php echo $plugin['stars_fmt']; ?></td>
			</tr>
			<tr>
				<td>官方评级：</td>
				<td><?php echo $plugin['user_stars_fmt']; ?></td>
			</tr>
			<tr>
				<td>安装次数：</td>
				<td><?php echo $plugin['installs']; ?></td>
			</tr>
			<tr>
				<td>销售次数：</td>
				<td><?php echo $plugin['sells']; ?></td>
			</tr>
			<tr>
				<td>通过官方认证：</td>
				<td><?php if($plugin['is_cert']) { ?><span class="green bold">通过</span><?php } else { ?><span class="red bold">未通过</span><?php } ?></td>
			</tr>
		<?php } ?>	
		<tr>
			<td></td>
			<td>
				<button class="small blue" id="plugin_install_button">安装</button> 　
				<button class="small red" id="plugin_unstall_button">卸载</button>
			</td>
		</tr>
		</table>
	</div>
</div>

<?php include './admin/view/footer.inc.htm';?>

<script>
var dir = '<?php echo $dir; ?>';
$('#plugin_install_button').on('click', function() {
	$.xget('plugin/'+dir+'/install.php', function(code, message) {
		if(code == 0) {
			$('#plugin_install_button').button('disabled');
			$('#plugin_unstall_button').button('reset');
			$.alert('安装成功');
		} else {
			$.alert(message);
		}
	});
});
$('#plugin_unstall_button').on('click', function() {
	$.xget('plugin/'+dir+'/unstall.php', function(code, message) {
		if(code == 0) {
			$.alert('卸载成功');
			$('#plugin_install_button').button('reset');
			$('#plugin_unstall_button').button('disabled');
		} else {
			$.alert(message);
		}
	});
});
<?php if($plugin['installed']) { ?>
$('#plugin_install_button').button('disabled');
<?php } else { ?>
$('#plugin_unstall_button').button('disabled');
<?php } ?>

</script>
